package org.jeecg.modules.cosmetic.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.cosmetic.handler.ToxicologicalCsaHandler;
import org.jeecg.modules.cosmetic.model.vo.DeleteVO;
import org.jeecg.modules.cosmetic.model.vo.ToxCsaPickVO;
import org.jeecg.modules.cosmetic.model.vo.ToxCsaVO;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 毒理数据库CIR_SCCS_AICIS模块表 前端控制器
 * </p>
 *
 * @author lq
 * @since 2024-02-29 13:57:48
 */
@Api(tags = "csa模块")
@RestController
@RequestMapping("/api/tox/csa")
public class TToxicologicalCsaController {

    @Resource
    private ToxicologicalCsaHandler toxicologicalCsaHandler;

    @ApiOperation(value = "上传文件", notes = "上传文件")
    @PostMapping(value = "/upload")
    public Result<?> upload(@RequestParam(value = "file") MultipartFile file) {
        return toxicologicalCsaHandler.upload(file);
    }

    @ApiOperation(value = "保存-更新数据", notes = "保存-更新数据")
    @PostMapping(value = "/save_update")
    public Result<?> saveOrupdate(@RequestBody List<ToxCsaVO> list) {
        return toxicologicalCsaHandler.saveOrupdate(list);
    }

    @ApiOperation(value = "查询数据", notes = "查询数据")
    @GetMapping(value = "/get")
    public Result<?> getCSA(@RequestParam("id") Long id, @RequestParam("form") Integer form) {
        return Result.ok(toxicologicalCsaHandler.getCSA(id, form));
    }

    @ApiOperation(value = "查询CSA模块数据详情", notes = "查询CSA模块数据详情")
    @GetMapping(value = "/detail")
    public Result<?> getCSADetail(@RequestParam("id") Long id) {
        return Result.ok(toxicologicalCsaHandler.getCSA(id, null));
    }

    @ApiOperation(value = "查询数据是否为优选", notes = "查询数据是否为优选")
    @GetMapping(value = "/get_pick")
    public Result<?> getCSAPick(@RequestParam("id") Long id, @RequestParam("form") Integer form) {
        return Result.ok(toxicologicalCsaHandler.getCSAPick(id, form));
    }

    @ApiOperation(value = "选择/取消优选", notes = "选择/取消优选")
    @PutMapping(value = "/update_pick")
    public Result<?> updateCSAPick(@RequestBody List<ToxCsaPickVO> voList) {
        return toxicologicalCsaHandler.updateCSAPick(voList);
    }

    @ApiOperation(value = "删除数据", notes = "删除数据")
    @DeleteMapping(value = "/delete")
    public Result<?> delete(@RequestBody DeleteVO vo) {
        return Result.ok(toxicologicalCsaHandler.delete(vo.getId()));
    }

}
